package net.huashitong.ssydt.exam.entity.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import net.huashitong.ssydt.exam.entity.SsExamPaperRecord;
import net.huashitong.ssydt.exam.entity.SsExamQuestion;

import java.util.ArrayList;
import java.util.List;

/**
 * @author <a href="mailto:yhy23456@163.com">huiyang.yu</a>
 * @since 2017.09.05
 */
@ApiModel(value = "PaperRecordOutVO", description = "试卷记录对象")
public class PaperRecordOutVO extends BaseRecord {

    private static final long serialVersionUID = 3786212972210013591L;
    @ApiModelProperty(value = "试卷名称")
    private String paperName;//试卷名称

    @ApiModelProperty(value = "选择题列表")
    private List<PaperQuestion> questions;

    public PaperRecordOutVO(SsExamPaperRecord ssExamPaperRecord) {
        this.paperName = ssExamPaperRecord.getPaperName();
        this.setCoefficient(ssExamPaperRecord.getCoefficient());
        this.setQuestionNumber(ssExamPaperRecord.getQuestionNumber());
        this.setRecordId(ssExamPaperRecord.getId());
        this.setTestState(ssExamPaperRecord.getTestState());
        this.setFinishNumber(ssExamPaperRecord.getFinishNumber());
        this.setCorrectNumber(ssExamPaperRecord.getCorrectNumber());
        this.setCorrectAvgRate(ssExamPaperRecord.getCorrectAvgRate());
        this.setBeatRate(ssExamPaperRecord.getBeatRate());
        this.setUserTime(ssExamPaperRecord.getUserTime());
    }

    public String getPaperName() {
        return paperName;
    }

    public void setPaperName(String paperName) {
        this.paperName = paperName;
    }

    public List<PaperQuestion> getQuestions() {
        return questions;
    }

    public void setQuestions(List<PaperQuestion> questions) {
        this.questions = questions;
    }

    public static class PaperQuestion extends BaseRecordQuestion {

        private static final long serialVersionUID = -4599030496863893936L;

        @ApiModelProperty(value = "是否授权，true时可以刷题")
        private Boolean authorization = true;

        public PaperQuestion(SsExamQuestion ssExamQuestion, int sequence, boolean authorization) {
            super(ssExamQuestion);
            this.authorization = authorization;
            this.setSequence(sequence);
            this.setIsTrue(false);
            this.setUserAnswers(new ArrayList<>());
        }

        public PaperQuestion() {
        }

        public void init() {
            this.authorization = false;
            this.setSequence(0);
            this.setIsTrue(false);
            this.setUserAnswers(new ArrayList<>());

            this.setQuestionId(0L);
            this.setQuestion("");
            this.setAnalysis("");
            this.setQuestionType("");
            this.setIsEmphasis(false);
            this.setIsCard(false);
            this.setOptions(new ArrayList<>());
        }


        public Boolean getAuthorization() {
            return authorization;
        }

        public void setAuthorization(Boolean authorization) {
            this.authorization = authorization;
        }
    }
}
